package bar;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Tset1 {

	public int getMoneyPlay(String phone) throws IOException {
		File file = new File("net-log.txt");
		FileReader fr = new FileReader(file);
		BufferedReader bf = new BufferedReader(fr);
		SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String str = "";
		long d1 = 0L;
		long d2 = 0L;
		while ((str = bf.readLine()) != null) {
			String[] s = str.split(",");
			if (s[0].equals(phone) && s[1].equals("up")) {
				try {
					d1 = a.parse(s[2]).getTime();
				} catch (ParseException e) {
					e.printStackTrace();
				}
			} else if (s[0].equals(phone) && s[1].equals("down")) {
				try {
					d2 = a.parse(s[2]).getTime();
				} catch (ParseException e) {
					e.printStackTrace();
				}
			}
		}
		double time = ((d2 - d1) / 1800) / 1000;
		return (int) Math.ceil(time);
	}
	public static void main(String[] args) throws IOException {
		Tset1 a = new Tset1();
		System.out.println(a.getMoneyPlay("123455678901"));
		
	}
}
	
